package com.ruoyi.project.jiaqin.viprecord.service.impl;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.jiaqin.viprecord.mapper.JiaqinBuyvipRecordMapper;
import com.ruoyi.project.jiaqin.viprecord.domain.JiaqinBuyvipRecord;
import com.ruoyi.project.jiaqin.viprecord.service.IJiaqinBuyvipRecordService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 钻石VIP购买记录Service业务层处理
 *
 * @author admin
 * @date 2021-01-04
 */
@Service
public class JiaqinBuyvipRecordServiceImpl implements IJiaqinBuyvipRecordService
{
    @Autowired
    private JiaqinBuyvipRecordMapper jiaqinBuyvipRecordMapper;

    /**
     * 查询钻石VIP购买记录
     *
     * @param id 钻石VIP购买记录ID
     * @return 钻石VIP购买记录
     */
    @Override
    public JiaqinBuyvipRecord selectJiaqinBuyvipRecordById(String id)
    {
        return jiaqinBuyvipRecordMapper.selectJiaqinBuyvipRecordById(id);
    }

    @Override
    public JiaqinBuyvipRecord selectJiaqinBuyvipRecordByRecordId(String recordId) {

        return jiaqinBuyvipRecordMapper.selectJiaqinBuyvipRecordByRecordId(recordId);
    }

    /**
     * 查询钻石VIP购买记录列表
     *
     * @param jiaqinBuyvipRecord 钻石VIP购买记录
     * @return 钻石VIP购买记录
     */
    @Override
    public List<JiaqinBuyvipRecord> selectJiaqinBuyvipRecordList(JiaqinBuyvipRecord jiaqinBuyvipRecord)
    {
        return jiaqinBuyvipRecordMapper.selectJiaqinBuyvipRecordList(jiaqinBuyvipRecord);
    }

    /**
     * 新增钻石VIP购买记录
     *
     * @param jiaqinBuyvipRecord 钻石VIP购买记录
     * @return 结果
     */
    @Override
    public int insertJiaqinBuyvipRecord(JiaqinBuyvipRecord jiaqinBuyvipRecord)
    {
        jiaqinBuyvipRecord.setId(UUID.randomUUID().toString().replace("-",""));
        return jiaqinBuyvipRecordMapper.insertJiaqinBuyvipRecord(jiaqinBuyvipRecord);
    }

    /**
     * 修改钻石VIP购买记录
     *
     * @param jiaqinBuyvipRecord 钻石VIP购买记录
     * @return 结果
     */
    @Override
    public int updateJiaqinBuyvipRecord(JiaqinBuyvipRecord jiaqinBuyvipRecord)
    {
        return jiaqinBuyvipRecordMapper.updateJiaqinBuyvipRecord(jiaqinBuyvipRecord);
    }

    /**
     * 删除钻石VIP购买记录对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteJiaqinBuyvipRecordByIds(String ids)
    {
        return jiaqinBuyvipRecordMapper.deleteJiaqinBuyvipRecordByIds(Convert.toStrArray(ids));
    }

    @Override
    public JiaqinBuyvipRecord generate(String memberId, BigDecimal money) {
        JiaqinBuyvipRecord jiaqinBuyvipRecord = new JiaqinBuyvipRecord();
        jiaqinBuyvipRecord.setMemberId(memberId);//设置用户ID
        jiaqinBuyvipRecord.setCreateAt(new Date());//设置生成时间
        jiaqinBuyvipRecord.setMoney(money);//设置需支付金额
        jiaqinBuyvipRecord.setState(0);//设置时间
        jiaqinBuyvipRecord.setRecordId((new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()))+(int)(Math.random()*1000));
        insertJiaqinBuyvipRecord(jiaqinBuyvipRecord);
        return jiaqinBuyvipRecord;
    }

    /**
     * 删除钻石VIP购买记录信息
     *
     * @param id 钻石VIP购买记录ID
     * @return 结果
     */
    @Override
    public int deleteJiaqinBuyvipRecordById(String id)
    {
        return jiaqinBuyvipRecordMapper.deleteJiaqinBuyvipRecordById(id);
    }
}
